Skip to content

Use one grid cell per model input, and have the method name span multiple rows#2995

Merged
robertbrignull merged 2 commits intomainfrom
robertbrignull/model-table-multirow
Oct 19, 2023
Merged

Use one grid cell per model input, and have the method name span multiple rows#2995
robertbrignull merged 2 commits intomainfrom
robertbrignull/model-table-multirow

Conversation

@robertbrignull
Copy link
Copy Markdown
Contributor

This follows on from #2990.

This addresses the point of using MultiModelColumn to fit multiple inputs for a certain field but different models into a single grid cell. Instead, we use one grid cell per input, and use gridRow="span N" to make the method name span multiple rows.

Here's what it looks like:
Screenshot 2023-10-18 at 15 16 39

I've used a narrow window width so things flow onto multiple lines. The grid lines are visible because I've highlighted that element in the developer tools. Sadly the grid lines don't show where cells span multiple rows/columns, but you can see by the contents that it's working.

Checklist

  • CHANGELOG.md has been updated to incorporate all user visible changes made by this pull request.
  • Issues have been created for any UI or other user-facing changes made by this pull request.
  • [Maintainers only] If this pull request makes user-facing changes that require documentation changes, open a corresponding docs pull request in the github/codeql repo and add the ready-for-doc-review label there.

@robertbrignull robertbrignull requested a review from a team as a code owner October 18, 2023 14:27
<>
<DataGridCell>
<ModelTypeDropdown
key={index}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was a little concerned about removing these keys. I've done manual tested and I haven't seen anything not updating correctly. Also, the default behaviour if you don't specify a key is to use the index.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the key can be removed here since this is not a top-level element in the map anymore. However, I think we should still add a key on the <> that is now the top-level literal. The only reason ESLint doesn't give an error is that it doesn't seem to detect it on <>, but changing it to its concrete implementation (using <Fragment> instead of <>) does give the error.

If we don't add the key there, we will get an error in the next major version of eslint-react: https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-key.md#checkfragmentshorthand-default-false. It's probably best to add it by changing it to <Fragment key={index}>.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah nice. I did try adding a key but it won't even allow it on a <>. Good suggestion to switch to <Fragment> instead.

Base automatically changed from robertbrignull/model-table-alignment to main October 19, 2023 08:57
@robertbrignull robertbrignull merged commit 86b5056 into main Oct 19, 2023
@robertbrignull robertbrignull deleted the robertbrignull/model-table-multirow branch October 19, 2023 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants